<%-- 
    Document   : hadeeth
    Created on : Oct 21, 2010, 12:28:41 PM
    Author     : M Bilal
--%>


<%@ page import="wap.rockvilletech.portal.DBProc" %>
<%@ page import="java.io.*,java.text.*"%>

<%@ page import="org.apache.log4j.Logger" %>
<%final Logger log = Logger.getLogger("JSP.HADITH");%>
<%@include file="../includes/header.jspf"%>


<%
thisPage="Religion-Hadith";
DBProc dbp = DBProc.getInstance();
int intBlockLength = 10,intRecordsToBeDisplayed = 0,intRecordsToBeFetched = 0;
String strPagingLinks = "";
// Vars for PAGING
boolean computePaging = false,
        isNext = true;
int intCountTotal = 0,intPageID = 0,intLastPage = 0;
Vector vHadeeth = new Vector();
String id="", CatID="", pid="", bid="";
boolean isList = false;

id = request.getParameter("id") != null ? request.getParameter("id").toString() : "";
CatID = request.getParameter("CatID") != null ? request.getParameter("CatID").toString() : "";
pid = request.getParameter("pid") != null ? request.getParameter("pid").toString() : "0";
bid = request.getParameter("bid") != null ? request.getParameter("bid").toString() : "";


if(request.getParameter("arg0") == null || request.getParameter("arg0").equalsIgnoreCase("null")) {
     try {

        vHadeeth = dbp.getHadith(pid, 0);
        intCountTotal = (Integer)(vHadeeth.get(0));
        intRecordsToBeDisplayed = intRecordsToBeFetched=(Integer)(vHadeeth.get(1));

    } catch (Exception ex) { }
    isList = true;
}else{
    try {
        int arg=Integer.parseInt(request.getParameter("arg0"));
        vHadeeth = dbp.getHadith(pid, arg);

        intCountTotal = (Integer)(vHadeeth.get(0));
        intRecordsToBeDisplayed = intRecordsToBeFetched=(Integer)(vHadeeth.get(1));

    } catch (Exception ex) { }

}

//log.debug("\nCatID: "+CatID+"\napp: "+app+"\nid : "+id+"\npid: "+pid+"\nbid: "+bid);

if(isList) {
    //check if list of books to be displayed
    try {
        intLastPage=intCountTotal/intRecordsToBeDisplayed;
        intPageID= Integer.parseInt(pid.toString());
        if (intPageID > intLastPage) intPageID = intLastPage;

        if (vHadeeth.size()+1 < intRecordsToBeFetched) {
            intRecordsToBeDisplayed -= (intRecordsToBeFetched - vHadeeth.size());
            intRecordsToBeFetched = vHadeeth.size();
            isNext = false;
        }
      } catch (Exception ex) { }
}else {
    try {
        intLastPage = intCountTotal-1;
        intPageID= Integer.parseInt(pid.toString());
        if (intPageID > intLastPage) intPageID = intLastPage;
        intRecordsToBeFetched=1;
        intRecordsToBeDisplayed = 1;
        isNext=Integer.parseInt(pid)== intCountTotal-1?false:true;

    } catch (Exception ex) { }
}

//--log.debug("Size of VHadeeth.size()  : "+vHadeeth.size());
computePaging = vHadeeth.size() == 0 ? false : true;

if (computePaging) {
    // Call the method which will generate Page links
    wap.rockvilletech.util.Paging.computePaging(request, "hadeeth.jsp?", intRecordsToBeFetched, intRecordsToBeDisplayed,
                     intCountTotal, intBlockLength, intLastPage, intPageID, isNext);

    // Get the generated Summary and links
    strPagingLinks = wap.rockvilletech.util.Paging.getPagingLinks();
}

%>
<div style="padding: 5px 0px 0px 0px;">
    <div class="div_navigation" id="div_navigation">
        <a href="<%=context_Path%>" class="LinkIndex">Home</a>&nbsp;&gt;
        <a href="<%=context_Path%>/religion/index.jsp" class="LinkIndex">Religion</a>&nbsp;&gt;
    <span class="navigation_Leaf">Hadith</span>
    </div>
</div>
    
        <table width="100%" align="left" cellpadding="0" cellspacing="0" style="text-align: left;font-weight: bold;">
                        <tr>
                            <td style="background-image:url('../images/new/top_bar_02.jpg');background-repeat: repeat-x;height:26px;">
                            <b style='padding:0px 0px 0px 2px;'>Hadith</b>
                            </td>
                        </tr>
         </table>
    <div style="height:1px;clear: both;"> &nbsp; </div>
<div style="padding:5px 0px 0px 2px;" align="left">
<%

if(isList){
for(int i=2;i<vHadeeth.size();i++){
    String[] temp = (String[])vHadeeth.get(i);
%>
<a class="" href="<%=context_Path%>/religion/hadeeth.jsp?src=<%=temp[1]%>&id=<%=id%>&pid=0&CatID=<%=CatID%>&bid=0&arg0=<%=temp[2]%>" >
        <img src="<%=context_Path%>/images/bullet-dot-green.png" alt=""/>&nbsp;<%=temp[1]%>
</a><br/>
<%}%>
      <%--  <div class="divStepFoot"><%=strPagingLinks%></div> --%>
<%
}else{
        String[] temp = (String[])vHadeeth.get(2);
%>
        <b>Source:</b>&nbsp;<%=temp[1]%><br/>
        <b>Volume:</b>&nbsp;<%=temp[2]%><br/>
        <b>Book:</b>&nbsp;<%=temp[5]%><br/>
        <b>Hadith No:</b>&nbsp;<%=intPageID+1%><br/>
        <%=temp[0]%>
        <%=app="Hadith-Content"%>
      <%--  <div class="divStepFoot"><%=strPagingLinks%></div> --%>
<%}%>
</div>
<div class="divStepFoot"><%=strPagingLinks%></div>

<%@include  file="../includes/footer.jspf"%>


<%
wpb.LogVisit(strIP, thisPage, strGsm, strApn, strBrand, strModel, app, request.getQueryString());
%>